package ga.nqueens;

import junit.framework.TestCase;

/**
 * @author thiagoepdc
 *
 */
public class BoardTest extends TestCase {

	/**
	 * @param name
	 */
	public BoardTest(String name) {
		super(name);
	}

	/**
	 * 
	 */
	public void testHits() {

		int dimensao = 10;
		Board board = new Board(dimensao);
		
		//2,6,9,3,5,0,4,1,7,8
		board.addRainha(0, 2);
		board.addRainha(1, 6);
		board.addRainha(2, 9);
		board.addRainha(3, 3);
		board.addRainha(4, 5);
		board.addRainha(5, 0);
		board.addRainha(6, 4);
		board.addRainha(7, 1);
		board.addRainha(8, 7);
		board.addRainha(9, 8);
		
		assertEquals(1, board.hits());
	}
	
	/**
	 * 
	 */
	public void testHitsByQueen() {

		int dimensao = 10;
		Board board = new Board(dimensao);
		int[] expectedHits = new int[] {0, 0, 0, 0, 0, 0, 0, 0, 1, 1};
		
		//2,6,9,3,5,0,4,1,7,8
		board.addRainha(0, 2);
		board.addRainha(1, 6);
		board.addRainha(2, 9);
		board.addRainha(3, 3);
		board.addRainha(4, 5);
		board.addRainha(5, 0);
		board.addRainha(6, 4);
		board.addRainha(7, 1);
		board.addRainha(8, 7);
		board.addRainha(9, 8);
		
		int[] actualHitsByQueen = board.hitsByQueen();
		
		assertEquals(expectedHits.length, actualHitsByQueen.length);
		
		for (int i = 0; i < actualHitsByQueen.length; i++) {
			System.out.println("i: "+i +" "+ actualHitsByQueen[i]);
		}
		
		for (int i = 0; i < actualHitsByQueen.length; i++) {
			assertEquals(expectedHits[i], actualHitsByQueen[i]);
		}
	}

}
